package LOGIN; // 根据你的项目包名调整

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.xfengshopping.R;

public class LoginFragment extends Fragment {

    private EditText etAccount, etPassword;
    private Button btnLogin, btnRegister;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // 直接加载你提供的布局文件（无需修改布局）
        View view = inflater.inflate(R.layout.login, container, false);
        initViews(view);
        return view;
    }

    private void initViews(View view) {
        etAccount = view.findViewById(R.id.account);
        etPassword = view.findViewById(R.id.Password);
        btnLogin = view.findViewById(R.id.login);
        btnRegister = view.findViewById(R.id.register);

        btnRegister.setOnClickListener(v -> {
            showToast("跳转到注册页面");
        });
    }

    private void showToast(String message) {
        requireActivity().runOnUiThread(() ->
                Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
        );
    }
}